﻿using System.Web.Http;
using SmartStore.Core.Domain.Localization;
using SmartStore.Core.Security;
using SmartStore.Services.Localization;
using SmartStore.Web.Framework.WebApi;
using SmartStore.Web.Framework.WebApi.OData;
using SmartStore.Web.Framework.WebApi.Security;

namespace SmartStore.WebApi.Controllers.OData
{
    public class LanguagesController : WebApiEntityController<Language, ILanguageService>
	{
        [WebApiAuthenticate(Permission = Permissions.Configuration.Language.Create)]
		protected override void Insert(Language entity)
		{
			Service.InsertLanguage(entity);
		}

        [WebApiAuthenticate(Permission = Permissions.Configuration.Language.Update)]
        protected override void Update(Language entity)
		{
			Service.UpdateLanguage(entity);
		}

        [WebApiAuthenticate(Permission = Permissions.Configuration.Language.Delete)]
        protected override void Delete(Language entity)
		{
			Service.DeleteLanguage(entity);
		}

		[WebApiQueryable]
        [WebApiAuthenticate(Permission = Permissions.Configuration.Language.Read)]
        public SingleResult<Language> GetLanguage(int key)
		{
			return GetSingleResult(key);
		}
	}
}
